<div class="admin_table">

<?php echo CHtml::beginForm('','post',array('enctype'=>'multipart/form-data')); ?>

	<p class="note"><?php echo AdminModule::t('Fields with <span class="required">*</span> are required.'); ?></p>

	<?php echo CHtml::errorSummary(array($model)); ?>

	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'user_name'); ?>
		<?php echo CHtml::activeTextField($model,'user_name',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo CHtml::error($model,'user_name'); ?>
	</div>
	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'password'); ?>
		<?php echo CHtml::activePasswordField($model,'password',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo CHtml::error($model,'password'); ?>
	</div>
	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'emailID'); ?>
		<?php echo CHtml::activeTextField($model,'emailID',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo CHtml::error($model,'emailID'); ?>
	</div>
	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'first_name'); ?>
		<?php echo CHtml::activeTextField($model,'first_name',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo CHtml::error($model,'first_name'); ?>
	</div>
	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'last_name'); ?>
		<?php echo CHtml::activeTextField($model,'last_name',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo CHtml::error($model,'last_name'); ?>
	</div>

	<?php 
	    $models = Role::model()->findAllByAttributes(array('status'=> 'active')) ;
		 
		// format models as $key=>$value with listData
		$list = CHtml::listData($models, 'id', 'name') ;		
		// print_r( $list );
	?>
	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'role_id'); ?>
		<?php echo CHtml::activeDropDownList($model,'role_id',$list,array('onchange'=>"checkVendorRole()")); ?>
		<?php echo CHtml::error($model,'role_id'); ?>
	</div>
	<br/><br/><br/><br/><br/><br/><br/><br/><br/>
	<div id="vendor_details" style="display:none">
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_name'); ?>
		<?php echo CHtml::activeTextField($modelVendor,'vendor_name',array()); ?>
		<?php echo CHtml::error($modelVendor,'vendor_name'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_stateID'); ?>
		<?php echo CHtml::activeDropDownList($modelVendor,'vendor_stateID',State::getList('STATE-LIST', array()),array('empty'=>'Select State','ajax' => array(
			'type'=>'POST', //request type
			'url'=>ApplicationConfig::getURL("", "main", "searchValueCities", array()), //url to call.
			//Style: CController::createUrl('currentController/methodToCall')
			'update'=>'#Vendor_vendor_cityID', //selector to update
			//'data'=>'js:javascript statement' 
			//leave out the data key to pass all form values through
			))); ?>
		<?php echo CHtml::error($modelVendor,'vendor_stateID'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_cityID'); ?>
		<?php echo CHtml::activeDropDownList($modelVendor,'vendor_cityID',array(),array('empty'=>'Select City')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_cityID'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_type'); ?>
		<?php echo CHtml::activeDropDownList($modelVendor,'vendor_type',ApplicationConfig::app()->params['vendor_params']['type'],array('empty'=>'Select Type')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_type'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_address',array('style'=>'position:absolute')); ?>
		<?php echo CHtml::activeTextArea($modelVendor,'vendor_address',array('style'=>'margin-left:23%')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_address'); ?>
		</div>
		
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_description',array('style'=>'position:absolute')); ?>
		<?php echo CHtml::activeTextArea($modelVendor,'vendor_description',array('style'=>'margin-left:27%')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_description'); ?>
		</div>
		
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'subscription_email'); ?>
		<?php echo CHtml::activeTextField($modelVendor,'subscription_email',array()); ?>
		<?php echo CHtml::error($modelVendor,'subscription_email'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_logo_file'); ?>
		<?php echo CHtml::activeFileField($modelVendor,'vendor_logo_file',array()); ?>
		<?php echo CHtml::error($modelVendor,'vendor_logo_file'); ?>
		<?php if (!$modelVendor->isNewRecord){?>
		<img src="<?php echo ApplicationConfig::getImageUrl('VENDOR-IMAGES-THUMB', array('file_name'=>$modelVendor->vendor_logo_thumb))?>" width="100px" height="80px">
		<?php }?>
		</div>
	</div>
    <div class="clear"></div><br />
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>
    <div class="clear"></div><br />

	<div class="link">
<?php echo "".CHtml::link('Back to List',ApplicationConfig::getURL("admin", "Cpanel", "manage"),array()); ?>
</div>
<script type="text/javascript">
function checkVendorRole()
{
	if($('#Admin_role_id').val()=="2")
	{
		 $('#vendor_details').show('slow', function() {
			  });
	}
	else
	{
		 $('#vendor_details').hide('slow', function() {
		  });
	}
}
$(document).ready(function() {
	checkVendorRole();
	if($('#Vendor_vendor_stateID').val()){
	 <?php
             echo(CHtml::ajax(array
             (
                     'url'=>array(ApplicationConfig::getURL("", "main", "searchValueCities", array('stateID'=>$modelVendor->vendor_stateID,'cityID'=>$modelVendor->vendor_cityID))),
                     'update'=>'#Vendor_vendor_cityID',
             )));
     ?>
     
 	}
});
</script>

<?php echo CHtml::endForm(); ?>

</div><!-- form -->